home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10216 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP on string functions ????
  5. Date: Fri, 15 Mar 96 23:31:06 GMT
  6. Organization: none
  7. Message-ID: <826932666snz@genesis.demon.co.uk>
  8. References: <826150130.AA00176@escan.demon.co.uk>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!genesis.demon.co.uk
  13.  
  14. In article <826150130.AA00176@escan.demon.co.uk>
  15.            bill@escan.demon.co.uk "Bill Birrell" writes:
  16.  
  17. >    What's wrong with:-
  18. >
  19. >    char *p;
  20. >    *p='\0'; ?
  21.  
  22. This defines an unilitialised pointer and then tries to dereference it which
  23. is illegal. The problem is that while space has been allocated to hold a
  24. pointer, no space has been allocated to hold a char and the pointer doesn't
  25. point to anywhere valid.
  26.  
  27. >    alternatively you could write a funtion:-
  28. >
  29. >    void strset(char *p, char q)
  30. >    {
  31. >        *p=q;
  32. >    }
  33.  
  34. This encounters the same problem if you don't pass it a valid pointer to
  35. a character object.
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.